package com.zqx.observer.specficobserver;

import com.zqx.observer.abstractobserver.Observer;
import com.zqx.observer.abstracttarget.AllyControllerCenter;

/**
 * description: 具体观察者类
 * @author zqx
 * @date 2018/09/04
 */
public class Player implements Observer{

    private String name;

    public Player(String name) {
        this.name = name;
    }

    @Override
    public String getName() {
        return this.name;
    }

    @Override
    public void setName(String name) {
        this.name = name;
    }

    //支援盟友方法的实现
    @Override
    public void help() {
        System.out.println("坚持住，"+this.name+"来救你!");
    }

    //遭受攻击方法的实现，当遭受攻击时将调用战队控制中心类的通知方法notifyObserver()来通知盟友
    @Override
    public void beAttacked(AllyControllerCenter acc) {
        System.out.println(this.name+"被攻击!");
        acc.notifyObserver(name);
    }
}
